package xiao_jin.fantastic_journey.core.common.item.temp;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import xiao_jin.fantastic_journey.api.capability.Capability;
import xiao_jin.fantastic_journey.core.init.ModCapabilities;

public class ManaTest extends Item {
    public ManaTest() {
        super(new Settings());
    }

    @Override
    public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
        var item = user.getStackInHand(hand);
        if (world.isClient) return TypedActionResult.success(item);
        Capability.run(ModCapabilities.MANA_CAPABILITY, user, world.isClient(), (it) -> {
            it.addManaValue(user.isSneaking() ? -1 : 1);
            return null;
        });

        return TypedActionResult.success(item);
    }
}
